#pragma once

#include "FactoryLib/OcRxPublic.h"
#define DECLARE_Singleton(CLASS) \
public: \
  static CLASS* Instance(bool blnNew = true); \
  static void Clear(); \
protected: \
  static CLASS* _instance; \

#define IMPLEMENT_Singleton(CLASS) \
  void CLASS::Clear() \
{ \
  if (_instance) \
{ \
  delete _instance; \
  _instance = NULL; \
} \
} \
  CLASS* CLASS::_instance = NULL; \
  CLASS* CLASS::Instance (bool blnNew) \
{ \
  if (_instance == NULL && blnNew) \
  { \
  _instance = new CLASS; \
  } \
  return _instance; \
}\

  template<class T>
  class OCSingleton
  {
  public:
	  virtual ~OCSingleton(void);
  protected:
	  OCSingleton();

  public:

    static T* Instance(bool blnNew = TRUE);
    static void Clear();

  protected:

    static T* _instance;

  };


#include "OCSingleton.inl"


